package com.heima.minio;

import io.minio.MinioClient;
import io.minio.PutObjectArgs;
import io.minio.errors.*;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;

public class MinioDemo {
    public static void main(String[] args) throws Exception{
        InputStream inputStream = new FileInputStream("E:\\index.html");

        //1.创建minio的客户端
        MinioClient minioClient=MinioClient.builder().
                credentials("minio","minio123")
                .endpoint("http://192.168.35.135:9000").build();

        //2.执行上传操作
        PutObjectArgs putArgs=PutObjectArgs.builder()
                .object("list.html")//指定上传之后的文件名称
        .contentType("text/html")//文件类型
                .bucket("123")//指定上传文件的桶(目录)
                .stream(inputStream,inputStream.available(),-1)
        .build();
        minioClient.putObject(putArgs);
    }
}
